package com.shujia.day08.homework;


/*
    2.请使用面向对象的思想，设计自定义类，描述出租车和家用轿车的信息。  设定
    1)出租车类:
        属性包括：车型，车牌，所属出租公司；方法包括：启动，停止
    2)家用轿车类：
        属性包括：车型，车牌，车主姓名；方法包括：启动，停止
    要求
        1)分析出租车和家用轿车的公共成员，提取出父类—汽车类
        2)利用继承机制，实现出租车类和家用轿车类
        3)编写测试类，分别测试汽车类，出租车类和家用轿车类对象的相关方法
        定义名为 car 的包存放汽车类，出租车类，家用轿车类和测试类
 */
class Car{
    //车型，车牌
    private String carKind;
    private String carCard;

    public Car() {
    }

    public Car(String carKind, String carCard) {
        this.carKind = carKind;
        this.carCard = carCard;
    }

    public String getCarKind() {
        return carKind;
    }

    public void setCarKind(String carKind) {
        this.carKind = carKind;
    }

    public String getCarCard() {
        return carCard;
    }

    public void setCarCard(String carCard) {
        this.carCard = carCard;
    }

    public void start(){
        System.out.println("我是车，我启动");
    }

    public void stop(){
        System.out.println("我是车，我停止");
    }
}

class Taxi extends Car{
    private String company;

    public Taxi() {
    }

    public Taxi(String carKind, String carCard,String company) {
        super(carKind, carCard);
        this.company = company;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    @Override
    public void start() {
        System.out.println("乘客您好");
        System.out.println("我是"+company+"的，我的车牌是"+getCarCard()+"，您要去哪里？");
    }

    @Override
    public void stop() {
        System.out.println("目的地已经到了，请您付费下车，欢迎再次乘坐");
    }
}

class PrivateCar extends Car{
    private String pName;

    public PrivateCar() {
    }

    public PrivateCar(String carKind, String carCard, String pName) {
        super(carKind, carCard);
        /*
         this.carKind = carKind;
         this.carCard = carCard;
         */
        this.pName = pName;
    }

    @Override
    public void start() {
        System.out.println("我是"+pName+"，我的汽车我做主");
    }

    @Override
    public void stop() {
        System.out.println("目的地到了，我们去玩吧");
    }
}

public class Test4 {
    public static void main(String[] args) {
        Car car = new Car();
        car.start();
        car.stop();
        System.out.println("=====================");
        PrivateCar p1 = new PrivateCar("奥迪A8L霍希版", "皖A00001", "武大郎");
        p1.start();
        p1.stop();
        System.out.println("=====================");
        Taxi t1 = new Taxi("比亚迪", "京B123", "景顺出租车公司");
        t1.start();
        t1.stop();
    }
}
